package com.itcase.JDBC_02.controller;

import com.itcase.JDBC_02.domin.student;
import com.itcase.JDBC_02.service.studentServiceIMml;
import org.junit.Test;

import java.util.ArrayList;
import java.util.Date;

public class studentText {

    studentServiceIMml s =   new studentServiceIMml();
    //查看全部
    @Test
    public void findAll() {
        ArrayList<student> list = s.findAll();
        for (student stu : list) {
            System.out.println(stu);
        }
    }
    //条件查询
    @Test
    public  void findById(){
        student stu = s.findById(3);
        System.out.println(stu);
    }
//添加
    @Test
    public void insert() {
        student stu = new student(5,"周七",27,new Date());
        int result = s.insert(stu);
        if(result != 0) {
            System.out.println("新增成功");
        }else {
            System.out.println("新增失败");
        }
    }
    @Test
    public void update() {
        student stu = s.findById(5);
        stu.setName("周七七");

        int result = s.update(stu);
        if(result != 0) {
            System.out.println("修改成功");
        }else {
            System.out.println("修改失败");
        }
    }
    //删除
    @Test
    public void delete() {
        int result = s.delete(5);

        if(result != 0) {
            System.out.println("删除成功");
        }else {
            System.out.println("删除失败");
        }
    }
}